package gr.atc.epart;

import gr.atc.epart.actions.Action;
import gr.atc.epart.actions.ActionComment;
import gr.atc.epart.net.RetrievalFailedException;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import android.app.ListActivity;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.Toast;

public class DisplayCommentsActivity extends ListActivity {



	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.listview);
		
		
		List<ActionComment> comments = new ArrayList<ActionComment>();
		
		
		Action selectedAction = EPartVolatileDataStore.getInstance()
		.getSelectedAction();
		
		int actionId = selectedAction.getId();
		EPartClient client = new EPartClient();
		
		//TODO make it endless 
		try {
			comments = client.getComments(actionId, 1, 50);
		} catch (RetrievalFailedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		CommentsAdapter commentAdapter = new CommentsAdapter(this, comments);
		setListAdapter(commentAdapter);

	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {

		super.onListItemClick(l, v, position, id);
//
//		int last = (l.getCount() - 1);
//		if (position == last) {
//			commentAdapter.update();
//
//		}

	}

	
}
